﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page isELIgnored="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<form method="get" action="admin/query" id="listform">
	<div class="panel admin-panel">
		<div class="panel-head">
			<strong class="icon-reorder"> 管理员列表</strong> <a href="admin/add"
				style="float: right; display: none;">添加管理员</a>
		</div>
		<div class="padding border-bottom">
			<ul class="search" style="padding-left: 10px;">
				<li><a class="button border-main icon-plus-square-o"
					href="admin/add"> 添加管理员</a></li>

				<li>
				<input type="hidden" name="pageNum" value="1">
				<input type="hidden" name="pageSize" value="5">
				<input type="hidden" name="queryName" value="account">
				<input type="text" placeholder="请输入搜索关键字" name="queryValue"
					value="" class="input"
					style="width: 250px; line-height: 17px; display: inline-block" />
					<a href="javascript:void(0)" class="button border-main icon-search"
					onclick="dosearch();"> 搜索</a></li>
			</ul>
		</div>
		<table class="table table-hover text-center">
			<tr>
				<th width="100" style="text-align: left; padding-left: 20px;">ID</th>
				<th>头像</th>
				<th>管理员账号</th>
				<th>管理员邮箱</th>
				<th width="310">操作</th>
			</tr>
			<c:choose>
				<c:when test="${null != admins && fn:length(admins) > 0}">
					<c:forEach items="${admins}" var="admin">
					<tr>
						<td style="text-align: left; padding-left: 20px;">
						<input type="checkbox" name="id[]" value="1" />${admin.adminId}
						</td>
			          <td width="10%">
			          <img src="${admin.head}" alt="" width="70" height="50" />
			          </td>
						<td width="10%">${admin.account}</td>
						<td>${admin.email}</td>
						<td>
							<div class="button-group">
								<a class="button border-main" href="admin/find/${admin.adminId}"></span> 修改</a> 
								<a class="button border-red" href="admin/delete/${admin.adminId}" /><span class="icon-trash-o">删除</span>
								</a>
							</div>
						</td>
					</tr>
					</c:forEach>
					<tr>
						<td><input type="checkbox" id="checkall" /> 全选</td>
						<td colspan="7" style="text-align: left; padding-left: 20px;"><a
							href="javascript:void(0)" class="button border-red icon-trash-o"
							style="padding: 5px 15px;" onClick="DelSelect(this)"> 删除</a></td>
					</tr>
					<tr>
						<td colspan="8">
							<div class="pagelist">
								总页数: ${page.pages}&nbsp;&nbsp; 当前第 ${page.pageNum} 页&nbsp;&nbsp; 
								<a href="admin/query?queryName=${queryPreperty.queryName}&queryValue=${queryPreperty.queryValue}&pageNum=${page.navigateFirstPage}&pageSize=5">首页</a> 
								<a href="admin/query?queryName=${queryPreperty.queryName}&queryValue=${queryPreperty.queryValue}&pageNum=${page.prePage}&pageSize=5">上一页</a>
								<a href="admin/query?queryName=${queryPreperty.queryName}&queryValue=${queryPreperty.queryValue}&pageNum=${page.nextPage}&pageSize=5">下一页</a>
								<a href="admin/query?queryName=${queryPreperty.queryName}&queryValue=${queryPreperty.queryValue}&pageNum=${page.navigateLastPage}&pageSize=5">尾页</a>
							</div>
						</td>
					</tr>

				</c:when>
				<c:otherwise>

					<tr>
						<td colspan="7">无默认数据,请搜索!</td>
					</tr>

				</c:otherwise>
			</c:choose>

		</table>
	</div>
</form>
<script type="text/javascript">

//搜索
function dosearch(){
	document.forms[0].submit();
}

//单个删除
function del(id,mid,iscid){
	if(confirm("您确定要删除吗?")){
		
	}
}

//全选
$("#checkall").click(function(){ 
  $("input[name='id[]']").each(function(){
	  if (this.checked) {
		  this.checked = false;
	  }
	  else {
		  this.checked = true;
	  }
  });
})

//批量删除
function DelSelect(){
	var Checkbox=false;
	 $("input[name='id[]']").each(function(){
	  if (this.checked==true) {		
		Checkbox=true;	
	  }
	});
	if (Checkbox){
		var t=confirm("您确认要删除选中的内容吗？");
		if (t==false) return false;		
		$("#listform").submit();		
	}
	else{
		alert("请选择您要删除的内容!");
		return false;
	}
}

</script>